﻿$(function () {
    var uploadedItem = new qq.FileUploader({
        element: document.getElementById('upload_img'),
        action: '../DataService.asmx/UpdateLogo',
        allowedExtensions: ['jpg', 'png'],
        autoUpload: true,
        progressBar: 'qq-progress-bar',
        minSizeLimit: 0,
        uploadButtonText: "Upload Logo",
        multiple: false,
        debug: true
    });

});

function UpdateContributorsPage() {
    if ($('#txtContributors').val() == "") {
        $('#lblContributors').css('display', 'inherit');
    } else {

        $('#lblContributors').css('display', 'none');
        ajaxCall('../DataService.asmx/UpdateContributors', false, '{"link": "' + $('#txtContributors').val() + '"}',
                    function () {
                        alert("Update was succesfull");
                        $('#txtContributors').val("");
                    },
                    function () {
                        alert("Error happend while updating data in the database");
                    }
                );
    }
}

function UpdateFacebookPage() {
    if ($('#txtFacebook').val() == "") {
        $('#lblFacebook').css('display', 'inherit');
    } else {
        $('#lblFacebook').css('display', 'none');
        ajaxCall('../DataService.asmx/UpdateFacebook', false, '{"link": "' + $('#txtFacebook').val() + '"}',
                    function () {
                        alert("Update was succesfull");
                        $('#txtFacebook').val("");
                    },
                    function () {
                        alert("Error happend while updating data in the database");
                    }
                );
    }
}

function UpdateTwitterPage() {
    if ($('#txtTwitter').val() == "") {
        $('#lblTwitter').css('display', 'inherit');
    } else {
        $('#lblTwitter').css('display', 'none');
        ajaxCall('../DataService.asmx/UpdateTwitter', false, '{"link": "' + $('#txtTwitter').val() + '"}',
                    function () {
                        alert("Update was succesfull");
                        $('#txtTwitter').val("");
                    },
                    function () {
                        alert("Error happend while updating data in the database");
                    }
                );
    }

}

function UpdateLinkedinPage() {
    if ($('#txtLinkedin').val() == "") {
        $('#lblLinkedin').css('display', 'inherit');
    } else {
        $('#lblLinkedin').css('display', 'none');
        ajaxCall('../DataService.asmx/UpdateLinkedin', false, '{"link": "' + $('#txtLinkedin').val() + '"}',
                    function () {
                        alert("Update was succesfull");
                        $('#txtLinkedin').val("");
                    },
                    function () {
                        alert("Error happend while updating data in the database");
                    }
                );
    }

}

function UpdateYouTubeVideo() {
    if ($('#txtHomeVideo').val() == "") {
        $('#lblYouTube').css('display', 'inherit');
    } else {
        $('#lblYouTube').css('display', 'none');
        ajaxCall('../DataService.asmx/UpdateYouTube', false, "{'link': '" + $('#txtHomeVideo').val() + "'}",
                    function () {
                        alert("Update was succesfull");
                        $('#txtHomeVideo').val("");
                    },
                    function () {
                        alert("Error happend while updating data in the database");
                    }
                );
    }
}